package com.hp.teach.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.hp.teach.domain.Student;
import com.hp.teach.domain.TeachClasses;
import com.hp.teach.mapper.ClassesMapper;
import com.hp.teach.mapper.StudentMapper;
import com.hp.teach.mapper.TeachClassesMapper;
import com.hp.teach.service.IHomePageService;
/**
 * 查询首页接口
 * @author 86150
 *
 */
@Service
public class HomePageServiceImpl implements IHomePageService {
	
	@Autowired
	private StudentMapper studentMapper;
	@Autowired
	private TeachClassesMapper teachClassesMapper;

	/**
	 * 查询首页个数
	 */
	@Override
	public List<Map<String,Object>>  getTeachCountInfo() {
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		Map<String,Object> stuMap = new HashMap<String,Object>();
		// 查询在读学生
		List<Student> stuList = studentMapper.selectclassStudents(new Student());
		stuMap.put("count", stuList.size());
		stuMap.put("name", "在读学生");
		list.add(stuMap);
		// 查询班级
		Map<String,Object> classMap = new HashMap<String,Object>();
		List<TeachClasses> classList = teachClassesMapper.selectTeachClassesList(new TeachClasses());
		classMap.put("count", classList.size());
		classMap.put("name", "班级数");
		list.add(classMap);
		// 查询宿舍数
		Map<String,Object> dormitoryMap = new HashMap<String,Object>();
		List<String> sfList = studentMapper.getDormitoryInfo();
		dormitoryMap.put("count", sfList.size());
		dormitoryMap.put("name", "宿舍数");
		list.add(dormitoryMap);

		//查询总毕业人数【数据还是个死的】
		Map<String,Object> dormitoryMap1 = new HashMap<String,Object>();
		List<String> sfList1 = studentMapper.getDormitoryInfo();
		dormitoryMap1.put("count", sfList1.size());
		dormitoryMap1.put("name", "毕业人数");
		list.add(dormitoryMap1);
		return list;
	}

}
